/**
 * 
 */
package com.bysj.lms.utils;

import org.apache.shiro.crypto.hash.SimpleHash;

/**
 * @author abreu
 *
 */
public class EncryptUtil {
    
    /**
     * 加密算法
     */
    public static String algorithmName = "md5";
    /**
     * 加密算法迭代加密次数
     */
    public static int hashIterations = 2;
    /**
     * 加密编码 hex为true，toBase为false
     */
    public static boolean hexEncode = true;
    /**
     * 
     * 描述：对信息进行MD5盐值加密
     * @author xiaojiakai
     * @version 1.0
     * @param password
     * @param salt
     * @return String
     * @since 1.8
     *
     */
    public static String encrypt(String password, String salt){
        SimpleHash hash = new SimpleHash(algorithmName, password, salt, hashIterations);
        if(hexEncode){
            return hash.toHex();
        }else{
            return hash.toBase64();
        }
    }


}
